/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.bitoon.basketdudes.jpa;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 *
 * @author paco
 */
@Entity
@Table(name = "coleccion", schema="basket")
@NamedQueries({
    @NamedQuery(name = "Coleccion.findAll", query = "SELECT c FROM Coleccion c order by c.id"),
    @NamedQuery(name = "Coleccion.findById", query = "SELECT c FROM Coleccion c WHERE c.id = :id"),
    @NamedQuery(name = "Coleccion.findByMarcaId", query = "SELECT c FROM Coleccion c WHERE c.marcaId = :marcaId  order by c.id"),
    @NamedQuery(name = "Coleccion.findByNombre", query = "SELECT c FROM Coleccion c WHERE c.nombre = :nombre"),
    @NamedQuery(name = "Coleccion.findByDescripcion", query = "SELECT c FROM Coleccion c WHERE c.descripcion = :descripcion")})
public class Coleccion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private Short id;
    @Basic(optional = false)
    @Column(name = "marca_id")
    private short marcaId;
    @Basic(optional = false)
    @Column(name = "nombre")
    private String nombre;
    @Basic(optional = false)
    @Column(name = "descripcion")
    private String descripcion;

/*
 *  DESDE COLECCION NO SE PUEDEN RECUPERAR LAS ROPAS, PORQUE SINO NO PODEMOS
 *  RECUPERAR LAS ROPAS DE UNA COLECCIÓN DESDE ROPA.
 *
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "coleccion", fetch = FetchType.LAZY)
    private Ropa ropa;
 *
 *  OJO
*/
    public Coleccion() {
    }

    public Coleccion(Short id) {
        this.id = id;
    }

    public Coleccion(Short id, short marcaId, String nombre, String descripcion) {
        this.id = id;
        this.marcaId = marcaId;
        this.nombre = nombre;
        this.descripcion = descripcion;
    }

    public Short getId() {
        return id;
    }

    public void setId(Short id) {
        this.id = id;
    }

    public short getMarcaId() {
        return marcaId;
    }

    public void setMarcaId(short marcaId) {
        this.marcaId = marcaId;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }
/*
    public Ropa getRopa() {
        return ropa;
    }

    public void setRopa(Ropa ropa) {
        this.ropa = ropa;
    }
*/
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Coleccion)) {
            return false;
        }
        Coleccion other = (Coleccion) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bitoon.basketdudes.jpa.Coleccion[id=" + id + "]";
    }

}

